package com.training.java.core.collections.pre15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * This demo is to observe the List behavior Added different cellphones to the
 * list and the values are read
 * 
 * @author soumya
 * 
 */
public class CellPhoneImmutableDemo {

	public static void main(String[] args) {

		CellPhoneImmutable phone1 = new CellPhoneImmutable("Apple", "iPhone4s",
				"iOS6", 256);
		CellPhoneImmutable phone2 = new CellPhoneImmutable("Samsung", "Nexus5",
				"Android OS", 396);
		CellPhoneImmutable phone3 = new CellPhoneImmutable("Sony", "Xperia",
				"Android OS", 256);

		List cellPhones = new ArrayList();

		// Adding the cell phones to the list

		cellPhones.add(phone1);
		cellPhones.add(phone2);
		cellPhones.add(phone3);

		// reading the list

		Iterator phoneIterator = cellPhones.iterator();

		while (phoneIterator.hasNext()) {
			CellPhoneImmutable phones = (CellPhoneImmutable) phoneIterator
					.next();

			System.out.println(" Cell Phone  Company : " + phones.getCompany());
			System.out.println(" Cell Phone  Model : " + phones.getModel());
			System.out.println(" Cell Phone operatingSystem : "
					+ phones.getOpeartingSystem());
			System.out.println(" Cell Phone Price  : " + phones.getPrice());
			System.out.println("  ");
		}

	}

}
